package leetcode.code1221;

public class Solution extends Solution1221 {

	@Override
	public int balancedStringSplit(String s) {
		int r = 0;
		int rnum = 0;
		int lnum = 0;
		int ans = 0;
		char[] arr = s.toCharArray();
		int len = arr.length;
		final char R = 'R';
		while (r < len) {
			if (arr[r] == R) {
				rnum++;
			} else {
				lnum++;
			}
			if (rnum == lnum) {
				ans++;
				rnum = 0;
				lnum = 0;
			}
			r++;
		}
		return ans;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
